package com.go.dp.observer.three;

class Child implements Runnable {
	private Dad dad;

	public Child(Dad dad) {
		this.dad = dad;
	}

	public void wakeUp() {
		this.dad.feed();
	}

	@Override
	public void run() {
		try {
			System.out.println("child sleeping ... ");
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		wakeUp();
	}

}

class Dad {
		public void feed() {
		System.out.println("feed child!");
	}
}

public class MyClass {
	public static void main(String[] args) {
		Dad dad = new Dad();
		new Thread(new Child(dad)).start();
	}
}
